package com.ncmmall.domain.business.goods.sku;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.ncmmall.domain.business.goods.Goods;
import com.ncmmall.domain.business.goods.attribute.GoodsAttribute;
import com.ncmmall.domain.security.user.WebUser;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.persistence.*;

/**
 * 商品SKU
 *
 * @author linxs
 * @date 2019-06-27 22:07
 */
@Entity
@Table(name = "mall_goods_sku")
@Access(AccessType.FIELD)
@Getter
@Setter
@Accessors(chain = true)
public class GoodsSku {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @JsonBackReference
    @JoinColumn(name = "goodsId")
    @ManyToOne
    private Goods goods;

    /**
     * 销售规格一
     */
    @OneToOne
    private GoodsAttribute attribute1;

    /**
     * 销售规格二
     */
    @OneToOne
    private GoodsAttribute attribute2;

    /**
     * 销售规格三
     */
    @OneToOne
    private GoodsAttribute attribute3;

    /**
     * 销售规格四
     */
    @OneToOne
    private GoodsAttribute attribute4;

    /**
     * 销售规格四
     */
    @OneToOne
    private GoodsAttribute attribute5;

    /**
     * 供应商对应的sku
     */
    @OneToOne
    private GoodsSku issuingSku;

    /**
     * 所属商家
     */
    @OneToOne
    @JsonBackReference
    private WebUser merchant;

    /**
     * SKU编码，由多个商品规格的ID组成（如：16-21，表示该sku是规格16与21的组合）
     */
    private String skuNo;

    /**
     * sku名称，由多个商品规格的名称组成（如：16寸，17寸）
     */
    private String skuNames;

    /**
     * 商家编码（非必填，展示用）
     */
    private String code;

    /**
     * 库存数
     */
    private int store;

    /**
     * 销售价
     */
    private double price;

    /**
     * 一键代发价
     */
    private double issuingPrice;

    /**
     * 特价活动库存数
     */
    private int bargainStore;

    /**
     * 特价活动销售价
     */
    private double bargainPrice;

    /**
     * 秒杀活动库存数
     */
    private int seckillStore;

    /**
     * 秒杀活动销售价
     */
    private double seckillPrice;

    /**
     * 秒杀活动限购数
     */
    private int seckillLimit;

    /**
     * 预售价格
     */
    private double presellPrice;

    /**
     * 预售订金
     */
    private double presellSubscription;

    /**
     * 预售订金可减的金额
     */
    private double presellDeduction;

    /**
     * 预售尾款
     */
    private double presellRetainage;

    /**
     * 拼团库存
     */
    private int groupBookingStore;

    /**
     * 拼团价格
     */
    private double groupBookingPrice;


    private int skuLever1Count;
    private int skuLever2Count;
    private int skuLever3Count;
    private int skuLever4Count;
    private int skuLever5Count;

    private double skuLever1Price;
    private double skuLever2Price;
    private double skuLever3Price;
    private double skuLever4Price;
    private double skuLever5Price;

}

